<template>
  <div class="recomm">
    <div class="recomm_title">猜你喜欢</div>
    <div class="recomm_li" v-for="item in albums" :key="item.albumId">
      <!-- 替换成router-link -->
      <a href="javascript:;">
        <div class="li_img">
          <img :src="'https://imagev2.xmcdn.com/'+item.albumCoverPath"/>
          <div class="play_btn">
            <div class="play_ic">
              <van-icon name="play" />
            </div>
        </div>
        </div>
        
        <div class="li_text">
          <p>{{ item.albumTitle }}</p>
          <div class="li_track">
          <div>
            <span><van-icon name="manager-o" size="13" /> {{ formatNumber(String(item.albumPlayCount)) }}</span>
            <span><van-icon name="service" size="13" /> {{ formatNumber(String(item.albumTrackCount)) }}</span>
          </div>
        </div>
        </div>
      </a>
    </div>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue';
import {reqGuess} from '../../../api/detail/index'
import type {AB} from '../../../api/detail/type'
import { formatNumber } from 'vant/lib/utils';
const albums=ref<AB[]>([]);
onMounted(()=>{
  getGuess();
})
//请求猜你喜欢数据

const getGuess=async()=>{
  
  try {
    let res=await reqGuess();
    if(res.ret==200){
      albums.value=res.data.albums;
    }
  } catch (error) {-
    console.log(error);
    
  }
}

</script>

<style lang="less" scoped>
.recomm_title {
color: #333;
font-size: 18px;
font-weight: 700;
margin-bottom: 20px;
}
.recomm_li {
  width: 345px;
  height: 80px;
  margin: 15px 0;
  a{
    display: flex;
  }
}
.li_img {
  flex-shrink: 0;
  width: 70px;
  height: 70px;
  margin-right: 15px;
  
  position: relative;
  img{
    width: 70px;
    height: 70px;
    border-radius: 12px;
  }
}
.li_text {
  font-weight: 400;
  font-size: 16px;
  line-height: 1.38;
  color: #40404c;
  p{
    margin: 0;
    margin-bottom: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  
}
.li_track {
  width: 260px;
  height: 18px;
  font-size: 12px;
  line-height: 1.5;
  color: #999;
  font-weight: 400;
  span{
    margin: 0;
    margin-right: 10px;
   }
}
.play_btn {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,.3);
color: #fff;
border-radius: 12px;

}
.play_ic {
  width: 14px;
  height: 15px;
  position: absolute;
  top: 20px;
  left: 20px;
}
</style>